#include "common.h"    
    
int server_init(int port){ 
 
    struct sockaddr_in server;
    memset(&server, 0, sizeof(server));
    server.sin_family = AF_INET;
    server.sin_port = htons(port);
    server.sin_addr.s_addr = htonl(INADDR_ANY);
    
    int listenfd;
    listenfd = socket(AF_INET, SOCK_STREAM, 0);
    if(bind(listenfd, (struct sockaddr*)&server, sizeof(server)) == -1){
        return -1;
    }

    if(listen(listenfd, 10) == -1){
        return -1;
    }

    return listenfd;
}    